/*
 * create:2016年4月8日 上午9:40:13
 * author:wangds  
 */
package com.cxkj.shop.biz.timelimitpay;

import java.util.Map;

import javax.servlet.http.HttpSession;

import com.cxkj.shop.form.DefaultDelivery;
import com.cxkj.shop.form.Delivery;
import com.cxkj.shop.model.shoppingcart.ShoppingCart;
import com.cxkj.shop.model.shoppingcart.ShoppingCartUtils;
import com.cxkj.shop.utils.BusinessUtils;

import net.wangds.comp.business.http.AbstractHttpInteractionBusiness;
import net.wangds.comp.json.JsonUtil;

/**
 * .
 * 
 * @author wangds
 *
 */
public class RemoveTimeLimitPayFromCartBusiness extends AbstractHttpInteractionBusiness<Map<String,Object>, Delivery> {

  /*
   * @see net.wangds.common.processor.Processor#process()
   * 
   * @author wangds 2016年4月8日 上午9:40:36.
   */
  @Override
  public void process() throws Exception {
    DefaultDelivery<ShoppingCart> res = new DefaultDelivery<ShoppingCart>();
    try {
      HttpSession ssn = BusinessUtils.getHttpSessionFromHttpBusiness(this);

      ShoppingCart cart = BusinessUtils.getShoppingCartFromSession(ssn);
      Map<String,Object> form = this.getInput();
      this.getLogger().debug("grouppay2cart from:"+JsonUtil.toJson(form));
      
      int id = Integer.valueOf((String)form.get("timelimitpayId"));
      
      ShoppingCartUtils.removeTimeLimitPay(cart, id);
      res.setData(cart);
      res.setSuccess(true);
    } catch (Exception e) {
      this.getLogger().error(e.getLocalizedMessage(), e);
      e.printStackTrace();
    }finally{
      res.setPostTs(System.currentTimeMillis());
    }
    this.setResult(res);

  }

}
